package com.glela.platform.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.glela.platform.mapper.UserRemarkMapper;
import com.glela.platform.model.UserRemark;
import com.glela.platform.model.response.ResponsrUserRemark;
import com.glela.platform.service.UserRemarkService;
@Service("userRemarkService")
public class UserRemarkServiceImpl implements UserRemarkService{

	@Autowired
	private UserRemarkMapper userRemarkMapper;
	
	@Override
	public int insertRemark(long userId, long remarkManId, String remark) {
		// TODO Auto-generated method stub
		UserRemark userRemark=userRemarkMapper.selectUserRemark(userId, remarkManId);
		if(userRemark==null){
			userRemarkMapper.insertRemark(userId, remarkManId, remark);
			return 1;
		}else{
			userRemarkMapper.updateRemark(remark, userId, remarkManId);
			return 1;
		}
		
	}

	@Override
	public int updateRemark(String remark, long userId, long remarkManId) {
		// TODO Auto-generated method stub
		return userRemarkMapper.updateRemark(remark, userId, remarkManId);
	}

	@Override
	public ResponsrUserRemark selectUserRemark(long userId, long remarkManId) {
		// TODO Auto-generated method stub
		ResponsrUserRemark responsrUserRemark=new ResponsrUserRemark();
		UserRemark userRemark=userRemarkMapper.selectUserRemark(userId, remarkManId);
		if(userRemark==null){
			return responsrUserRemark;
		}
		responsrUserRemark.setUserId(userRemark.getUserId());
		responsrUserRemark.setRemarkManId(userRemark.getRemarkManId());
		responsrUserRemark.setRemark(userRemark.getRemark());
		return responsrUserRemark;
	}

	
	
}
